package com.example.demo.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.config.RedisCacheWriterCustomer;
import com.example.demo.dao.UserMapper;
import com.example.demo.entity.LoginUser;
import com.example.demo.entity.User;
import com.example.demo.intf.TestInterface;

/**
 * @author 88377761
 *
 */
@RestController
public class TestImpl implements TestInterface {

	/**
	 * @param name
	 * @return create by zy 88377761
	 */

	@Autowired
	UserMapper userMapper;

	@Override
	@Cacheable(value = "mytest" + RedisCacheWriterCustomer.REDIS_EXPIRE_TIME_KEY + 120)
	public String test(String name) {
		return "hello " + name + new Date();
	}

	public void testShardingsphere1() {
		User user = new User();
		user.setUserName("test33");
		userMapper.insert(user);
		List<User> list = userMapper.selectAll();
		for (User u : list)
			System.err.println(u.getUserName());
	}

	@Override
	@Cacheable(value = "test2" + RedisCacheWriterCustomer.REDIS_EXPIRE_TIME_KEY + 120)
	public String test2(LoginUser user) {
		return user.getUserNikename() + new Date();
	}

}
